/* Login page is standalone, all related CSS is here */

@font-face {
  font-family: "Red Hat Text";
  font-style: normal;
  font-weight: 400 500;
  src: url("fonts/RedHatText/RedHatTextVF.woff2") format("woff2-variations");
  font-display: fallback;
}

@font-face {
  font-family: "Red Hat Text";
  font-style: italic;
  font-weight: 400 500;
  src: url("fonts/RedHatText/RedHatTextVF-Italic.woff2") format("woff2-variations");
  font-display: fallback;
}

@font-face {
  font-family: "Red Hat Display";
  font-style: normal;
  font-weight: 400 700;
  src: url("fonts/RedHatDisplay/RedHatDisplayVF.woff2") format("woff2-variations");
  font-display: fallback;
}

@font-face {
  font-family: "Red Hat Display";
  font-style: italic;
  font-weight: 400 700;
  src: url("fonts/RedHatDisplay/RedHatDisplayVF-Italic.woff2") format("woff2-variations");
  font-display: fallback;
}

@font-face {
  font-family: RedHatText;
  font-style: normal;
  font-weight: 400;
  src: url(fonts/RedHatText-Regular.woff2) format("woff2");
  font-display: fallback;
}

@font-face {
  font-family: RedHatText;
  font-style: normal;
  font-weight: 700;
  src: url(fonts/RedHatText-Medium.woff2) format("woff2");
  font-display: fallback;
}

:root {
  --color-background: #fff; // pf-t--global--background--color--100
  --color-body-background: #f2f2f2; // pf-t--global--background--color--200

  --color-text: #151515;
  --color-text-light: #999;
  --color-text-lighter: #737373;
  --color-text-white: #fff;
  --color-secondary-text: #26292d;

  --color-primary: #06c;
  --color-primary-active: #004080;
  --color-link: var(--color-primary);
  --color-link-active: var(--color-primary-active);

  --color-border: #c7c7c7;
  --color-border-light: #72767b;

  --color-input-background: var(--color-background);
  --color-input: #151515;

  --color-danger: #c9190b;
  --color-danger-dark: #a30000;
  --color-warning: #f0ab00;
  --color-warning-dark: #c58c00;

  --color-status-danger-background: #faeae8;
  --color-status-danger-text: #a30000;
  --color-status-danger-accent: #c9190b;

  --color-status-warning-background: #fdf7e7;
  --color-status-warning-text: #795600;
  --color-status-warning-accent: #f0ab00;

  --color-status-info-background: #e7f1fa;
  --color-status-info-text: #004368;
  --color-status-info-accent: #73bcf7;

  --color-disabled-background: #555;
  --color-disabled-text: #d2d2d2;

  --color-error-background: #1e2125;
  --color-error: #fe5142;

  --pf-t--global--spacer--xs: 0.25rem;
  --pf-t--global--spacer--sm: 0.5rem;
  --pf-t--global--spacer--md: 1rem;
  --pf-t--global--spacer--lg: 1.5rem;
  --pf-t--global--spacer--xl: 2rem;
  --pf-t--global--spacer--2xl: 3rem;

  --pf-t--global--spacer--control--vertical: var(--pf-t--global--spacer--sm);
  --pf-t--global--spacer--control--vertical--compact: var(--pf-t--global--spacer--xs);
  --pf-t--global--spacer--control--horizontal: var(--pf-t--global--spacer--md);
  --pf-t--global--spacer--control--horizontal--compact: var(--pf-t--global--spacer--sm);

  --pf-t--global--spacer--gap--text-to-element: var(--pf-t--global--spacer--sm);

  --pf-t--global--icon--size--lg: 1rem;

  --pf-t--global--border--radius--sharp: 0px;
  --pf-t--global--border--radius--tiny: 4px;
  --pf-t--global--border--radius--small: 6px;
  --pf-t--global--border--radius--medium: 16px;
  --pf-t--global--border--radius--large: 24px;
  --pf-t--global--border--radius--pill: 999px;
  --pf-t--global--border--radius--legacy: 3px;
  --pf-t--global--border--radius--legacy-sharp: 1px;
}

.pf-v6-theme-dark {
  --color-background: #292929; // pf-t--global--dark--background--color--200
  --color-body-background: #151515; // pf-t--global--dark--background--color--100

  --color-text: #f0f0f0;
  --color-text-light: #999;
  --color-text-lighter: #999;
  --color-secondary-text: #f0f0f0;

  --color-link: #8ac0f6;
  --color-link-active: #8ac0f6;

  --color-border: #393f44;
  --color-border-light: #6c6f72;

  --color-input-background: #393f44;
  --color-input: #f0f0f0;

  --color-disabled-background: #444548;
  --color-disabled-text: #c6c7c8;

  --color-error-background: var(--color-secondary-background);
  --color-error: #fe5142;

  --color-status-danger-background: var(--color-error-background);
  --color-status-danger-text: var(--color-status-danger-accent);
  --color-status-warning-background: var(--color-error-background);
  --color-status-warning-text: var(--color-status-warning-accent);
  --color-status-info-background: var(--color-error-background);
  --color-status-info-text: var(--color-status-info-accent);
}

*,
::after,
::before {
  box-sizing: border-box;
}

[hidden]:not([hidden="false"]) {
  display: none !important;
}

html {
  block-size: 100vh;
}

body {
  margin: 0;
  font-family: "Red Hat Text", RedHatText, Helvetica, Arial, sans-serif;
  background-color: var(--color-body-background);
  color: var(--color-text);
  line-height: 1.5;
}

h1, h2, h3, h4 {
  font-size: 1.125rem;
  font-weight: 400;
  margin: 0;
}

h1 {
  font-size: 1.75rem;
  line-height: 1.3;
  padding-block: 0 var(--pf-t--global--spacer--md);
  padding-inline: 0;

  &#brand {
    font-size: 1.75rem;
  }
}

h2 {
  font-size: 1.3rem;
}

pre {
  white-space: pre-wrap;
}

.pf-v6-c-button,
label {
  font-weight: 500;
}

.pf-v6-c-button,
img {
  vertical-align: middle;
}

#option-group,
.pf-v6-c-button,
.input-clear,
button {
  cursor: pointer;
}

.input-clear {
  opacity: 0.7;
}

a,
summary {
  color: var(--color-link);
  text-decoration: none;

  &:focus,
  &:hover {
    --color-link: var(--color-link-active);
    text-decoration: underline;
  }
}

img {
  border: 0;
}

button,
input,
select,
textarea {
  font-family: inherit;
  margin: 0;
  font-size: inherit;
  line-height: inherit;
}

button {
  overflow: visible;
  border-radius: var(--pf-t--global--border--radius--pill);
  border: none;
}

button::-moz-focus-inner,
input::-moz-focus-inner {
  border: 0;
  padding: 0;
}

p {
  margin-block: 0 var(--pf-t--global--spacer--md);
  margin-inline: 0;
}

.container {
  margin-inline: auto;
}

/* Bump options & connection away from user/pass */
#option-group,
#option-group[hidden] + #server-group {
  margin-block-start: var(--pf-t--global--spacer--md);
}

#option-group {
  margin-block-end: var(--pf-t--global--spacer--md);
}

.form-group:not(:first-child) {
  margin-block-start: var(--pf-t--global--spacer--md);
}

.login-actions {
  display: flex;
  align-items: baseline;
  gap: var(--pf-t--global--spacer--md);
  padding-block-start: var(--pf-t--global--spacer--lg);
}

label {
  display: inline-block;
}

.control-label {
  font-size: 0.875rem;
}

[role="form"] .control-label,
form .control-label {
  display: flex;
  align-items: center;
  min-block-size: 2rem;
  padding-block: 0 var(--pf-t--global--spacer--control--vertical);
  padding-inline: 0;
}

.form-control {
  color: var(--color-input);
}

.pf-v6-c-button.pf-m-control,
.form-control[type="password"],
.form-control[type="text"] {
  display: block;
  inline-size: 100%;
  padding-block: var(--pf-t--global--spacer--control--vertical);
  padding-inline: var(--pf-t--global--spacer--control--horizontal);
  background-color: var(--color-input-background);
  background-image: none;
  border: 1px solid var(--color-border);
  border-radius: var(--pf-t--global--border--radius--small);
  transition: border-color 0.15s ease-in-out;
  color: var(--color-input);
}

:focus {
  outline: 2px solid var(--color-primary);
}

.form-control:focus {
  outline-offset: -6px;
}

.form-control::placeholder {
  color: var(--color-text-light);
  font-style: italic;
  opacity: 1;
}

.checkbox-row {
  margin-block: var(--pf-t--global--spacer--md) 0;
  margin-inline: 0;
  display: flex;
  align-items: baseline;
}

.checkbox-row > input[type="checkbox"] {
  inline-size: 1rem;
  block-size: 1rem;
  align-self: flex-start;
  margin-block-start: calc((1.5rem - 1rem) / 2);
  margin-inline-end: var(--pf-t--global--spacer--sm);
}

label.checkbox {
  font: inherit;
}

.help-block {
  display: block;
  margin-block: 5px var(--pf-t--global--spacer--md);
  color: var(--color-text-lighter);
}

.pf-v6-c-button,
.caret {
  display: inline-block;
}

.pf-v6-c-button[spinning] .spinner,
#login-wait-validating .spinner {
  display: inline-flex;
}

.form-group::after {
  clear: both;
  margin-block-end: var(--pf-t--global--spacer--md);
}

.pf-v6-c-button {
  text-align: center;
  white-space: nowrap;
  padding-block: 0.375rem;
  padding-inline: var(--pf-t--global--spacer--control--horizontal);
  border-radius: var(--pf-t--global--border--radius--pill);
  font-size: inherit;
  font-weight: 400;
  user-select: none;

  /* Base styles */
  background: var(--button-color-background, transparent);
  border: 1px solid var(--button-color-border, var(--color-primary));
  color: var(--button-color-text, var(--color-primary));

  &:active,
  &:not([disabled]):focus,
  &:not([disabled]):hover {
    --button-color-background: var(--button-color-hover-background, transparent);
    --button-color-border: var(--button-color-hover-border, var(--color-primary-active));
    --button-color-text: var(--button-color-hover-text, var(--color-primary-active));
    text-decoration: none;
  }

  &.pf-m-primary {
    --button-color-background: var(--color-primary);
    --button-color-border: var(--color-primary);
    --button-color-text: var(--color-text-white);
    --button-color-hover-background: var(--color-primary-active);
    --button-color-hover-border: var(--color-primary-active);
    --button-color-hover-text: var(--color-text-white);
  }

  &.pf-m-tertiary {
    --button-color-border: var(--color-input);
    --button-color-text: var(--color-input);
    --button-color-hover-border: var(--color-input);
    --button-color-hover-text: var(--color-input-hover);

    &:hover {
      text-decoration: underline
    }
  }

  &.pf-m-danger {
    --button-color-background: var(--color-danger);
    --button-color-border: var(--color-danger);
    --button-color-text: var(--color-text-white);
    --button-color-hover-background: var(--color-danger-dark);
    --button-color-hover-border: var(--color-danger-dark);
    --button-color-hover-text: var(--color-text-white);
  }

  &.pf-m-warning {
    --button-color-background: var(--color-warning);
    --button-color-border: var(--color-warning);
    --button-color-text: black;
    --button-color-hover-background: var(--color-warning-dark);
    --button-color-hover-border: var(--color-warning-dark);
    --button-color-hover-text: black;
  }

  &:disabled {
    background-color: var(--color-disabled-background, lightgray);
    color: var(--color-disabled-text, gray);
    border-color: var(--button-color-disabled-border, gray);
    cursor: not-allowed;
    opacity: var(--button-disabled-opacity, 0.6);
  }
}

// Alerts
.pf-v6-c-alert {
  display: grid;
  grid-template: "icon content" / auto 1fr;
  gap: var(--pf-t--global--spacer--xs) var(--pf-t--global--spacer--sm);
  align-items: start;
  margin-block-end: var(--pf-t--global--spacer--lg);
  padding: var(--pf-t--global--spacer--md);
  border: 2px solid var(--alert-border-color, var(--color-status-info-accent));
  color: var(--text-color);
  background-color: var(--color-background);
  border-radius: var(--pf-t--global--border--radius--medium);

  .pf-v6-c-alert__icon {
    grid-column: icon;
  }

  .pf-v6-c-alert__title,
  .pf-v6-c-alert__description {
    grid-column: content;
  }

  .pf-v6-c-alert__icon {
    // vertically align the icon's top edge with the text; https://blog.kizu.dev/cap-height-align/
    margin-block-start: calc((1cap - 1ex) / 2);

    svg {
      display: block;
      block-size: var(--pf-t--global--icon--size--lg);
      inline-size: var(--pf-t--global--icon--size--lg);
      color: var(--alert-border-color);
    }
  }

  .pf-v6-c-alert__title {
    font-weight: 500;
  }

  p {
    margin: 0;
  }

  &.pf-m-plain {
    border: none;
    background: transparent;
    padding-block: 0;
    padding-inline: 0;
  }

  &.pf-m-inline {
    &.pf-m-danger {
      --alert-border-color: var(--color-status-danger-accent);
    }

    &.pf-m-warning {
      --alert-border-color: var(--color-status-warning-accent);
    }
  }
}

html body.login-pf {
  block-size: 100%;
  background: var(--color-body-background);
}

.login-pf #brand img {
  display: block;
  margin-block: 0;
  margin-inline: auto;
  max-inline-size: 100%;
}

.login-pf #banner {
  margin-block: var(--pf-t--global--spacer--md) var(--pf-t--global--spacer--sm);
  margin-inline: 0;
  grid-area: banner;
  inline-size: 100%;
}

#banner-message {
  white-space: pre-wrap;
  max-block-size: 12em;
  overflow: auto;
}

// Makes the borders and border-radius of the login cards look as it should
.login-pf .container {
  background: var(--color-background);
  color: var(--color-text);
  inline-size: 100%;
  border-radius: var(--pf-t--global--border--radius--large) var(--pf-t--global--border--radius--large);

  .container-body {
    padding: var(--pf-t--global--spacer--2xl);
  }

  .container-footer {
    padding-block: var(--pf-t--global--spacer--xl);
    padding-inline: var(--pf-t--global--spacer--2xl);
  }
}

#main {
  grid-area: login;
}

.login-pf .container .details p:first-child {
  border-block-start: 1px solid var(--color-secondary-text);
  padding-block-start: var(--pf-t--global--spacer--lg);
  margin-block-start: var(--pf-t--global--spacer--lg);
}

.login-pf .details p {
  margin: 0;
}

.login-pf .details p + p {
  margin-block-start: var(--pf-t--global--spacer--sm);
}

.login-pf .container .control-label {
  font-weight: 500;
}

.login-pf .container .help-block {
  color: unset;
}

.login-pf .container .form-group:last-child,
.login-pf .container .form-group:last-child .help-block:last-child {
  margin-block-end: 0;
}

.spinner {
  animation: 0.6s linear infinite rotation;
  border: 4px solid rgb(0 0 0 / 25%);
  border-block-start-color: rgb(0 0 0 / 75%);
  border-radius: 100%;
  block-size: 1.5rem;
  inline-size: 1.5rem;
}

#server-group::before {
  clear: both;
  margin-block-start: 5px;
}

.login-fatal {
  font-size: 130%;
}

.input-clear,
.inline .container .help-block {
  color: var(--color-text);
}

.caret,
.server-box {
  position: relative;
}

.conversation-prompt {
  white-space: normal;
  overflow-wrap: break-word;
}

.control-label {
  white-space: nowrap;
}

.spinner {
  border-color: rgb(255 255 255 / 75%) rgb(255 255 255 / 25%) rgb(255 255 255 / 25%);
}

html:not(.pf-v6-theme-dark) #login-wait-validating .spinner {
  border-color: rgb(51 51 51 / 75%) rgb(51 51 51 / 25%) rgb(51 51 51 / 25%);
}

#hostkey-fingerprint {
  font-size: large;
  font-weight: bold;
  margin-block-end: 0;
}

#hostkey-type {
  font-size: small;
}

#hostkey-verify-help-cmds {
  border-radius: 0.25rem;
  padding-block: var(--pf-t--global--spacer--sm);
  padding-inline: var(--pf-t--global--spacer--md);
  background: rgb(150 150 150 / 20%);
}

.pf-v6-c-button .spinner,
.pf-v6-c-button[spinning] .button-text,
.hide-before::before {
  display: none;
}

/* Hide inline login screen by default */
.inline #badge,
.inline #brand,
.inline #login-details {
  display: none;
}

.inline body {
  background: 0 0 !important;
  color: var(--color-background);
}

.pf-v6-c-expandable-section__toggle {
  display: inline-flex;
  align-items: center;
}

.caret {
  vertical-align: middle;
  margin-inline-end: var(--pf-t--global--spacer--xs);
  transition: all 300ms;

  [data-state="true"] &,
  details[open] > summary > & {
    transform: rotate(90deg);
  }

  path {
    fill: var(--color-text);
  }
}

.input-clear {
  display: flex;
  padding-block: var(--pf-t--global--spacer--sm);
  padding-inline: var(--pf-t--global--spacer--md);
  position: absolute;
  inset-block: 0;
  inset-inline-end: 0;
  align-items: center;

  > svg {
    block-size: 1rem;
    inline-size: auto;
  }

  /* Only show clear icon when the field has text */
  .form-control:placeholder-shown + & {
    display: none;
  }
}

/* Reserve a little space for the clear icon in the input */
.server-box > .form-control {
  padding-inline-end: var(--pf-t--global--spacer--2xl);
}

#option-group:hover svg,
.input-clear:hover {
  opacity: 1;
}

#option-group div {
  margin-inline-start: -3px;
  margin-block: 3px var(--pf-t--global--spacer--md);
}

.login-button {
  display: flex;
  align-items: center;
  justify-content: center;
  block-size: 2.5rem;
  flex-basis: 100%;
}

#hostkey-group:not([hidden]) ~ .login-actions > .login-button {
  flex-basis: max-content;
}

.pf-v6-c-button[disabled] {
  background-color: var(--color-disabled-background);
  background-image: none;
  border-color: var(--color-disabled);
  cursor: default;
}

/* PF4-ish style overrides (depending on grid & CSS variables */
.row {
  display: flex;
  flex-flow: column;
  margin: 0;
}

.login-pf .container .details p:first-child {
  border-block-start: 0;
  padding-block-start: 0;
  margin-block-start: 0;
}

.login-button {
  inline-size: 100%;
}

.login-pf .details {
  grid-area: details;
  inline-size: 100%;
  background: var(--color-background);
  border-radius: 0 0 var(--pf-t--global--border--radius--large) var(--pf-t--global--border--radius--large);
  border-block-start: 1px solid var(--color-border);
}

#recent-hosts {
  grid-area: recent;
  margin-block-start: 1rem;
  padding-block: 3rem 1.5rem;
  padding-inline: 1.5rem;
}

#recent-hosts > h1 {
  padding-inline-start: 1.5rem;
}

.login-pf #badge {
  grid-area: logo;
}

.login-pf .container .login-area {
  border: none;
  inline-size: auto;
}

details > summary {
  display: block;
  padding-block: var(--pf-t--global--spacer--sm);
  padding-inline: 0;
  cursor: pointer;
}

details > summary:hover {
  text-decoration: underline;
}

.login-pf #brand {
  text-transform: initial;
}

#brand strong,
#brand b {
  font-weight: 500;
}

.login-pf #brand.text-brand {
  inline-size: auto;
  background: none;
}

.host-line {
  display: grid;
  grid: 1fr / 1fr auto;
  border: 1px solid var(--color-border);
  border-width: 1px 0;
}

.host-line + .host-line {
  border-block-start-width: 0;
}

.host-name {
  flex: auto;
  text-align: start;
  color: var(--color-link);
  border: none;
  /* As we're making the list flush to the card, we should indent the contents to align */
  padding-block: 0.5rem;
  padding-inline: 1.5rem 1rem;
}

.host-name:hover {
  color: var(--color-link-active);
  text-decoration: underline;
}

.host-remove {
  background: transparent;
  margin-inline-end: 1.5rem;
  padding-block: 0.375rem;
  padding-inline: 1rem;
  /* Allow ::before to size relative to .host-remove */
  position: relative;

  &:focus {
    /* The × icon's focus ring */
    outline-color: var(--color-text);
  }

  /* As masking would hide outline, use ::before for the × SVG  */
  &::before {
    /* ::before pseudoelement needs special CSS to be visible */
    content: "";
    display: block;
    position: absolute;
    inset: 0;
    background-color: var(--color-text);
    border: none;
    mask: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='currentColor' viewBox='0 0 352 512'%3E%3Cpath d='m242.7 256 100-100a31.5 31.5 0 0 0 0-44.5l-22.2-22.3a31.5 31.5 0 0 0-44.4 0L176 189.2 76 89.3a31.5 31.5 0 0 0-44.5 0L9.2 111.5a31.5 31.5 0 0 0 0 44.4l100 100.1-100 100a31.5 31.5 0 0 0 0 44.5l22.3 22.3a31.5 31.5 0 0 0 44.4 0l100.1-100 100 100a31.5 31.5 0 0 0 44.5 0l22.3-22.2a31.5 31.5 0 0 0 0-44.5L242.8 256z'/%3E%3C/svg%3E");
    mask-size: var(--pf-t--global--icon--size--lg) var(--pf-t--global--icon--size--lg);
    opacity: 0.6;
  }

  &:focus::before,
  &:hover::before {
    opacity: 1;
  }
}

.unsupported-browser {
  #brand {
    display: none;
  }

  ul {
    display: inline-block;
    text-align: start;
    color: var(--color-text-lighter);
    margin-block: 0 1rem;
    margin-inline: 0;
  }

  a {
    font-weight: 700;
  }
}

.browser-recommendations {
  margin-block: 1rem 0;
  margin-inline: 0;

  h3 {
    font: inherit;
    margin-block-start: 0;
  }
}

#login-again {
  display: block;
  margin-block-start: 1rem;
}

.password-with-toggle {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--pf-t--global--spacer--xs);
}

.pf-v6-c-button.login-password-toggle {
  display: flex;
  align-items: center;
}

.login-password-toggle > svg {
  block-size: 1rem;
  inline-size: auto;
}

/* Show the appropriate eye icon based on the password text status */
input[type="text"] + .login-password-toggle .password-show,
input[type="password"] + .login-password-toggle .password-hide {
  display: none;
}

.pf-v6-c-helper-text {
  margin-block-start: 1rem;
}

.pf-v6-c-helper-text.pf-m-warning {
  color: var(--color-alert-warning-text);
}

/* Layout */
body.login-pf {
  --content-width: 38rem;
  --gap: 4rem;
  color: var(--color-input);
  display: grid;
  grid-template-areas:
    ". banner  ."
    ". .       ."
    ". login   ."
    ". details ."
    ". recent  ."
    ". .       ."
    ". logo    ."
    ". .       .";
  grid-template-rows: auto 1fr repeat(3, auto) var(--gap) auto 1fr;
  grid-template-columns: minmax(1rem, 1fr) minmax(auto, var(--content-width)) minmax(1rem, 1fr);
  gap: 0;
  justify-items: center;

  /* Desktop only */
  @media (width >=900px) {
    grid-template-areas:
      ". banner  banner ."
      ". .       .      ."
      ". login   logo   ."
      ". details logo   ."
      ". recent  logo   ."
      ". .       .      .";
    grid-template-rows: auto 1fr minmax(min-content, max-content) repeat(2, auto) 1fr;
    grid-template-columns: 1fr var(--content-width) auto 1fr;
    column-gap: var(--gap);

    #brand img {
      margin: 0;
      text-align: start;
    }
  }

  /* Mobile-specific */
  @media (width < 900px) {
    #badge {
      background-position: center;
      margin: 2rem;
    }
  }
}

/* Animation */
@keyframes rotation {
  from {
    transform: rotate(0);
  }

  to {
    transform: rotate(359deg);
  }
}
